import time
import unittest
from class_20200802.HTMLTestRunner_cn import HTMLTestRunner

from class_20200802.test_unittest import TestDemo

# # 第一步：创建一个测试套件，相当于一个包裹、空箱子
# suit = unittest.TestSuite()
#
# # 第二步：加载测试用例
# suit.addTest(TestDemo('test_add'))
# suit.addTest(TestDemo('test_add2'))
# suit.addTest(TestDemo('test_sub'))

case_dir = './'
discover = unittest.defaultTestLoader.discover(case_dir, pattern='test_*.py')

now = time.strftime("%Y-%m-%d_%H_%M_%S")
report_path = './Report/' + '自动化回归_' + now + '_result.html'

fp = open(report_path, "wb")
runner = HTMLTestRunner(title="自动化回归测试报告",
                        description="首页自动化回归测试报告，详情见附件",
                        stream=fp,
                        verbosity=2,
                        retry=2,
                        save_last_try=False)
runner.run(discover)
fp.close()

# 第三步：创建一个测试用例执行器,并执行测试套件里面的用例
# run = unittest.TextTestRunner()
# run.run(discover)
